<?php

use think\facade\Route;
use think\facade\Request;

$version = Request::header('version', 'v1');#接口版本
Route::group('', function () use ($version) {
    /**
     * 登录
     * 注册
     */
    Route::group('site', function () use ($version) {
        Route::post('login', "api/{$version}.Site/login");
        Route::post('reg', "api/{$version}.Site/register");
    });

    Route::group('pro', function () use ($version) {
        Route::post('get-info', "api/{$version}.pro/getinfo");
    });
    //获取导航和网站基础信息
    Route::group('navweb', function () use ($version) {
        Route::get('index', "api/{$version}.NavWeb/index");
    });

    //获取首页
    Route::group('index', function () use ($version) {
        Route::get('index', "api/{$version}.index/index");
        Route::get('list', "api/{$version}.index/list");
    });

    //获取滞销产品
    Route::group('unsalable', function () use ($version) {
        Route::get('index', "api/{$version}.unsalable/index");
    });

    //获取司机报名
    Route::group('driver', function () use ($version) {
        Route::get('index', "api/{$version}.driver/index");
    });

    //获取供应合作
    Route::group('coop', function () use ($version) {
        Route::get('index', "api/{$version}.coop/index");
    });

    //获取行情资讯
    Route::group('info', function () use ($version) {
        Route::get('index', "api/{$version}.info/index");
        Route::get('but', "api/{$version}.info/but");
        Route::get('content', "api/{$version}.info/content");
    });

    //获取公司黄页
    Route::group('company', function () use ($version) {
        Route::get('index', "api/{$version}.company/index");
        Route::get('company', "api/{$version}.company/company");
        Route::get('newcompany', "api/{$version}.company/newcompany");
    });

    //获取行情大厅
    Route::group('quotation', function () use ($version) {
        Route::get('index', "api/{$version}.quotation/index");
        Route::get('quotation', "api/{$version}.quotation/quotation");
        Route::get('content', "api/{$version}.quotation/content");
    });

    //获取采购大厅
    Route::group('purchase', function () use ($version) {
        Route::get('index', "api/{$version}.purchase/index");
        Route::get('cates', "api/{$version}.purchase/cates");
        Route::get('list', "api/{$version}.purchase/list");
        Route::get('content', "api/{$version}.purchase/content");
    });

    //获取供应大厅
    Route::group('supply', function () use ($version) {
        Route::get('index', "api/{$version}.supply/index");
        Route::get('cates', "api/{$version}.supply/cates");
        Route::get('list', "api/{$version}.supply/list");
        Route::get('content', "api/{$version}.supply/content");
    });


    /**
     * 会员管理
     */
    Route::group('member', function () use ($version) {
        Route::get('get-info', "api/{$version}.Member/getInfo");
    })->middleware('checkLogin');

})->allowCrossDomain([
    'Access-Control-Allow-Origin' => '*',
    'Access-Control-Allow-Methods' => 'GET,POST',
    'Access-Control-Allow-Headers' => 'content-type,token,version',
    'Access-Control-Allow-Credentials' => 'true'
]);